`use strict`

let login_fn=async (ctx,next)=>{
    let username=ctx.request.body.username || '';
    let password=ctx.request.body.password || '';
    if(username=== 'admin' && password ==='123'){
        ctx.redirect('/login/success');
    }else{
        ctx.redirect('/login/error');
    }
};


let login_success_fn= async (ctx,next)=>{
    ctx.body='<h1>登录成功~</h1>'
}
let login_error_fn= async (ctx,next)=>{
    ctx.body='<h1>登录失败</h1>'
}

module.exports={
    '/login':['post',login_fn],
    '/login/success':['get',login_success_fn],
    '/login/error':['get',login_error_fn]
}